<template>
  <div class="seller-order-management-container agri-page-container">
    <div class="page-header agri-page-header">
      <div class="page-title agri-page-title">
        <el-icon><List /></el-icon>
        <span>订单管理</span>
      </div>
    </div>

    <!-- 订单筛选卡片 -->
    <el-card class="filter-card agri-card">
      <div class="filter-container">
        <el-input
          v-model="searchQuery"
          placeholder="搜索订单号/买家信息"
          clearable
          class="filter-item"
          @input="handleFilterChange"
        >
          <template #prefix>
            <el-icon><Search /></el-icon>
          </template>
        </el-input>

        <el-select
          v-model="filterStatus"
          placeholder="订单状态"
          clearable
          class="filter-item"
          @change="handleFilterChange"
        >
          <el-option label="待付款" value="0" />
          <el-option label="待发货" value="1" />
          <el-option label="已发货" value="2" />
          <el-option label="已完成" value="3" />
          <el-option label="已取消" value="4" />
          <el-option label="退款中" value="5" />
          <el-option label="已退款" value="6" />
        </el-select>

        <el-date-picker
          v-model="dateRange"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD"
          class="filter-item date-range"
          @change="handleFilterChange"
        />

        <div class="filter-actions">
          <el-button type="primary" @click="handleFilterChange">筛选</el-button>
          <el-button @click="resetFilter">重置</el-button>
        </div>
      </div>
    </el-card>

    <!-- 订单列表 -->
    <el-card v-loading="loading" class="order-list-card agri-card">
      <template #header>
        <div class="card-header">
          <span class="card-title">订单列表</span>
          <div class="card-actions">
            <el-button type="success" size="small" @click="handleBatchShip" :disabled="selectedOrders.length === 0">
              批量发货
            </el-button>
          </div>
        </div>
      </template>

      <div v-if="filteredOrders.length === 0" class="empty-data">
        <el-empty description="暂无订单数据" />
      </div>
      
      <div v-else>
        <div class="agri-table-wrapper">
          <el-table
            ref="orderTableRef"
            :data="paginatedOrders"
            border
            style="width: 100%"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55" />
            <el-table-column prop="orderNumber" label="订单编号" width="180" />
            <el-table-column prop="buyerName" label="买家信息" min-width="150">
              <template #default="scope">
                <div>{{ scope.row.buyerName }}</div>
                <div class="order-buyer-phone">{{ scope.row.buyerPhone }}</div>
              </template>
            </el-table-column>
            <el-table-column label="商品信息" min-width="200">
              <template #default="scope">
                <div class="order-product">
                  <div class="order-product-name">{{ scope.row.productName }}</div>
                  <div class="order-product-price">¥{{ scope.row.price }} × {{ scope.row.quantity }}{{ scope.row.unit }}</div>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="totalAmount" label="订单金额" width="120">
              <template #default="scope">
                <span class="order-price">¥{{ scope.row.totalAmount }}</span>
              </template>
            </el-table-column>
            <el-table-column label="订单时间" width="180">
              <template #default="scope">
                {{ formatDate(scope.row.orderDate) }}
              </template>
            </el-table-column>
            <el-table-column prop="status" label="订单状态" width="100">
              <template #default="scope">
                <el-tag :type="getStatusType(scope.row.status)">
                  {{ getStatusText(scope.row.status) }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column label="操作" width="200" fixed="right">
              <template #default="scope">
                <div class="agri-operations">
                  <el-button
                    type="primary"
                    size="small"
                    @click="handleViewOrder(scope.row)"
                  >
                    查看
                  </el-button>
                  <el-button
                    v-if="scope.row.status === 'paid' || scope.row.status === 1"
                    type="success"
                    size="small"
                    @click="handleShipOrder(scope.row)"
                  >
                    发货
                  </el-button>
                  <el-button
                    v-if="['pending', 'paid'].includes(scope.row.status) || [0, 1].includes(scope.row.status)"
                    type="danger"
                    size="small"
                    @click="handleCancelOrder(scope.row)"
                  >
                    取消
                  </el-button>
                  <el-button
                    v-if="scope.row.status === 'refunding'"
                    type="warning"
                    size="small"
                    @click="handleRefundOrder(scope.row)"
                  >
                    退款
                  </el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>

        <!-- 分页 -->
        <div class="pagination-container">
          <el-pagination
            v-model:current-page="currentPage"
            v-model:page-size="pageSize"
            :page-sizes="[10, 20, 50]"
            layout="total, sizes, prev, pager, next, jumper"
            :total="filteredOrders.length"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </el-card>

    <!-- 订单详情对话框 -->
    <el-dialog
      v-model="orderDetailVisible"
      title="订单详情"
      width="800px"
    >
      <div v-if="currentOrder" class="order-detail">
        <div class="order-detail-header">
          <h3 class="order-number">订单编号：{{ currentOrder.orderNumber }}</h3>
          <el-tag :type="getStatusType(currentOrder.status)" class="order-status">
            {{ getStatusText(currentOrder.status) }}
          </el-tag>
        </div>

        <el-divider />

        <el-row :gutter="20">
          <el-col :span="12">
            <div class="detail-section">
              <h4 class="section-title">买家信息</h4>
              <div class="detail-item">
                <span class="detail-label">买家姓名：</span>
                <span class="detail-value">{{ currentOrder.buyerName }}</span>
              </div>
              <div class="detail-item">
                <span class="detail-label">联系电话：</span>
                <span class="detail-value">{{ currentOrder.buyerPhone }}</span>
              </div>
              <div class="detail-item">
                <span class="detail-label">收货地址：</span>
                <span class="detail-value">{{ currentOrder.address }}</span>
              </div>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="detail-section">
              <h4 class="section-title">订单信息</h4>
              <div class="detail-item">
                <span class="detail-label">下单时间：</span>
                <span class="detail-value">{{ formatDate(currentOrder.orderDate) }}</span>
              </div>
              <div class="detail-item">
                <span class="detail-label">支付方式：</span>
                <span class="detail-value">{{ getPaymentMethod(currentOrder.paymentMethod) }}</span>
              </div>
              <div class="detail-item">
                <span class="detail-label">配送方式：</span>
                <span class="detail-value">{{ getDeliveryMethod(currentOrder.deliveryMethod) }}</span>
              </div>
            </div>
          </el-col>
        </el-row>

        <div class="detail-section">
          <h4 class="section-title">商品信息</h4>
          <div class="agri-table-wrapper">
            <el-table :data="[currentOrder]" border style="width: 100%" class="product-table">
              <el-table-column prop="productName" label="商品名称" min-width="150" />
              <el-table-column prop="price" label="单价" width="100">
                <template #default="scope">
                  ¥{{ scope.row.price }}
                </template>
              </el-table-column>
              <el-table-column prop="unit" label="单位" width="80" />
              <el-table-column prop="quantity" label="数量" width="80" />
              <el-table-column label="小计" width="120">
                <template #default="scope">
                  ¥{{ (scope.row.price * scope.row.quantity).toFixed(2) }}
                </template>
              </el-table-column>
            </el-table>
          </div>
          
          <div class="order-amount">
            <div class="amount-item">
              <span class="amount-label">商品总额：</span>
              <span class="amount-value">¥{{ (currentOrder.price * currentOrder.quantity).toFixed(2) }}</span>
            </div>
            <div class="amount-item">
              <span class="amount-label">运费：</span>
              <span class="amount-value">¥{{ currentOrder.deliveryFee || '0.00' }}</span>
            </div>
            <div class="amount-item total">
              <span class="amount-label">订单总额：</span>
              <span class="amount-value">¥{{ currentOrder.totalAmount }}</span>
            </div>
          </div>
        </div>

        <div v-if="currentOrder.logistics" class="detail-section">
          <h4 class="section-title">物流信息</h4>
          <div class="detail-item">
            <span class="detail-label">物流公司：</span>
            <span class="detail-value">{{ currentOrder.logistics.company }}</span>
          </div>
          <div class="detail-item">
            <span class="detail-label">物流单号：</span>
            <span class="detail-value">{{ currentOrder.logistics.trackingNumber }}</span>
          </div>
          <div class="detail-item">
            <span class="detail-label">发货时间：</span>
            <span class="detail-value">{{ formatDate(currentOrder.logistics.shipDate) }}</span>
          </div>
        </div>

        <div v-if="currentOrder.note" class="detail-section">
          <h4 class="section-title">订单备注</h4>
          <div class="order-note">{{ currentOrder.note }}</div>
        </div>

        <div class="order-timeline">
          <h4 class="section-title">订单状态跟踪</h4>
          <el-timeline>
            <el-timeline-item
              v-for="(activity, index) in currentOrder.statusHistory"
              :key="index"
              :color="getTimelineColor(activity.status)"
              :timestamp="formatDate(activity.time)"
            >
              {{ getStatusText(activity.status) }}
              <p v-if="activity.remark" class="timeline-remark">{{ activity.remark }}</p>
            </el-timeline-item>
          </el-timeline>
        </div>
      </div>

      <template #footer>
        <span class="dialog-footer">
          <el-button @click="orderDetailVisible = false">关闭</el-button>
          <el-button 
            v-if="currentOrder && (currentOrder.status === 'paid' || currentOrder.status === 1)"
            type="primary" 
            @click="handleShipOrder(currentOrder)"
          >
            发货
          </el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 发货对话框 -->
    <el-dialog
      v-model="shipDialogVisible"
      title="订单发货"
      width="500px"
    >
      <el-form
        ref="shipFormRef"
        :model="shipForm"
        :rules="shipRules"
        label-width="100px"
        label-position="right"
      >
        <el-form-item label="物流公司" prop="company">
          <el-select v-model="shipForm.company" placeholder="请选择物流公司" style="width: 100%">
            <el-option label="顺丰快递" value="SF" />
            <el-option label="圆通快递" value="YTO" />
            <el-option label="中通快递" value="ZTO" />
            <el-option label="申通快递" value="STO" />
            <el-option label="韵达快递" value="YD" />
            <el-option label="邮政EMS" value="EMS" />
            <el-option label="京东物流" value="JD" />
            <el-option label="天天快递" value="TTKD" />
            <el-option label="百世快递" value="HTKY" />
          </el-select>
        </el-form-item>

        <el-form-item label="物流单号" prop="trackingNumber">
          <el-input v-model="shipForm.trackingNumber" placeholder="请输入物流单号" />
        </el-form-item>

        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="shipForm.remark"
            type="textarea"
            :rows="3"
            placeholder="可选填写发货备注信息"
          />
        </el-form-item>
      </el-form>

      <template #footer>
        <span class="dialog-footer">
          <el-button @click="shipDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="submitShipForm" :loading="submitting">确认发货</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { 
  List, Search, Timer, Calendar, Money, DataAnalysis
} from '@element-plus/icons-vue';
import { useSellerStore } from '../../store';
import { format } from 'date-fns';

// 状态管理
const sellerStore = useSellerStore();

// 列表数据和状态
const loading = ref(false);
const orders = ref([]);
const selectedOrders = ref([]);
const currentPage = ref(1);
const pageSize = ref(10);
const searchQuery = ref('');
const filterStatus = ref('');
const dateRange = ref([]);
const orderTableRef = ref(null);

// 统计数据
const orderStats = ref({});

// 对话框控制
const orderDetailVisible = ref(false);
const shipDialogVisible = ref(false);
const currentOrder = ref(null);
const submitting = ref(false);

// 发货表单
const shipFormRef = ref(null);
const shipForm = reactive({
  orderId: '',
  company: '',
  trackingNumber: '',
  remark: ''
});

// 表单验证规则
const shipRules = {
  company: [
    { required: true, message: '请选择物流公司', trigger: 'change' }
  ],
  trackingNumber: [
    { required: true, message: '请输入物流单号', trigger: 'blur' },
    { min: 5, max: 50, message: '长度在 5 到 50 个字符', trigger: 'blur' }
  ]
};

// 过滤后的订单列表
const filteredOrders = computed(() => {
  if (!orders.value.length) return [];
  
  let result = [...orders.value];
  
  // 搜索过滤
  if (searchQuery.value) {
    const query = searchQuery.value.toLowerCase();
    result = result.filter(order => 
      order.orderNumber.toLowerCase().includes(query) || 
      order.buyerName.toLowerCase().includes(query) ||
      order.buyerPhone.includes(query)
    );
  }
  
  // 状态过滤
  if (filterStatus.value) {
    // 将字符串转换为数字进行比较
    const statusNum = parseInt(filterStatus.value);
    result = result.filter(order => order.status === statusNum);
  }
  
  // 日期范围过滤
  if (dateRange.value && dateRange.value.length === 2) {
    const startDate = new Date(dateRange.value[0]);
    startDate.setHours(0, 0, 0, 0);
    
    const endDate = new Date(dateRange.value[1]);
    endDate.setHours(23, 59, 59, 999);
    
    result = result.filter(order => {
      const orderDate = new Date(order.orderDate);
      return orderDate >= startDate && orderDate <= endDate;
    });
  }
  
  return result;
});

// 分页后的订单列表
const paginatedOrders = computed(() => {
  const start = (currentPage.value - 1) * pageSize.value;
  const end = start + pageSize.value;
  return filteredOrders.value.slice(start, end);
});

// 获取状态类型
const getStatusType = (status) => {
  // 将数字状态转换为字符串状态
  let statusStr = '';
  if (typeof status === 'number') {
    switch (status) {
      case 0: statusStr = 'pending'; break;
      case 1: statusStr = 'paid'; break;
      case 2: statusStr = 'shipped'; break;
      case 3: statusStr = 'completed'; break;
      case 4: statusStr = 'cancelled'; break;
      case 5: statusStr = 'refunding'; break;
      case 6: statusStr = 'refunded'; break;
      default: statusStr = 'unknown';
    }
  } else {
    statusStr = status;
  }
  
  const types = {
    'pending': 'info',
    'paid': 'warning',
    'shipped': 'primary',
    'completed': 'success',
    'cancelled': 'danger',
    'refunding': 'warning',
    'refunded': 'info'
  };
  return types[statusStr] || 'info';
};

// 获取状态文本
const getStatusText = (status) => {
  // 直接根据数字状态返回文本
  if (typeof status === 'number') {
    switch (status) {
      case 0: return '待付款';
      case 1: return '待发货';
      case 2: return '已发货';
      case 3: return '已完成';
      case 4: return '已取消';
      case 5: return '退款中';
      case 6: return '已退款';
      default: return '未知状态';
    }
  }
  
  const texts = {
    'pending': '待付款',
    'paid': '待发货',
    'shipped': '已发货',
    'completed': '已完成',
    'cancelled': '已取消',
    'refunding': '退款中',
    'refunded': '已退款'
  };
  return texts[status] || '未知状态';
};

// 获取支付方式文本
const getPaymentMethod = (method) => {
  const methods = {
    'online': '在线支付',
    'cod': '货到付款',
    'transfer': '银行转账',
    'alipay': '支付宝',
    'wechat': '微信支付'
  };
  return methods[method] || '未知方式';
};

// 获取配送方式文本
const getDeliveryMethod = (method) => {
  const methods = {
    'express': '快递配送',
    'self': '自提'
  };
  return methods[method] || '未知方式';
};

// 获取时间线颜色
const getTimelineColor = (status) => {
  const colors = {
    'pending': '#909399',
    'paid': '#E6A23C',
    'shipped': '#409EFF',
    'completed': '#67C23A',
    'cancelled': '#F56C6C',
    'refunding': '#E6A23C',
    'refunded': '#909399'
  };
  return colors[status] || '#909399';
};

// 格式化日期
const formatDate = (date) => {
  if (!date) return '';
  return format(new Date(date), 'yyyy-MM-dd HH:mm');
};

// 筛选变化
const handleFilterChange = () => {
  currentPage.value = 1;
};

// 重置筛选条件
const resetFilter = () => {
  searchQuery.value = '';
  filterStatus.value = '';
  dateRange.value = [];
  handleFilterChange();
};

// 分页处理
const handleSizeChange = (val) => {
  pageSize.value = val;
  currentPage.value = 1;
};

const handleCurrentChange = (val) => {
  currentPage.value = val;
};

// 表格选择变化
const handleSelectionChange = (val) => {
  selectedOrders.value = val;
};

// 查看订单详情
const handleViewOrder = (order) => {
  currentOrder.value = order;
  orderDetailVisible.value = true;
};

// 发货处理
const handleShipOrder = (order) => {
  // 重置发货表单
  Object.assign(shipForm, {
    orderId: order.id,
    company: '',
    trackingNumber: '',
    remark: ''
  });
  
  if (shipFormRef.value) {
    shipFormRef.value.resetFields();
  }
  
  // 保存当前订单
  currentOrder.value = order;
  
  // 显示发货对话框
  shipDialogVisible.value = true;
};

// 提交发货表单
const submitShipForm = async () => {
  if (!shipFormRef.value) return;
  
  await shipFormRef.value.validate(async (valid) => {
    if (!valid) {
      return;
    }
    
    try {
      submitting.value = true;
      
      console.log('准备发货数据:', shipForm);
      
      // 发货
      const result = await sellerStore.shipOrder(shipForm);
      console.log('发货结果:', result);
      
      if (result && result.success) {
        ElMessage.success('订单发货成功');
        
        // 关闭对话框
        shipDialogVisible.value = false;
        orderDetailVisible.value = false;
        
        // 刷新订单列表
        fetchOrders();
      } else {
        ElMessage.error('发货失败: ' + (result?.message || '未知错误'));
      }
    } catch (error) {
      console.error('订单发货失败', error);
      ElMessage.error('订单发货失败: ' + (error.message || '未知错误'));
    } finally {
      submitting.value = false;
    }
  });
};

// 批量发货
const handleBatchShip = () => {
  if (selectedOrders.value.length === 0) {
    ElMessage.warning('请至少选择一个订单');
    return;
  }
  
  // 检查是否都是待发货状态
  const allPaid = selectedOrders.value.every(order => order.status === 'paid');
  if (!allPaid) {
    ElMessage.warning('只能批量发货待发货状态的订单');
    return;
  }
  
  ElMessageBox.confirm(
    `确定要批量发货选中的 ${selectedOrders.value.length} 个订单吗？`,
    '批量发货',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }
  ).then(async () => {
    try {
      loading.value = true;
      
      // 获取所有选中订单的ID
      const orderIds = selectedOrders.value.map(item => item.id);
      
      // 批量发货
      await sellerStore.batchShipOrders(orderIds);
      
      ElMessage.success('批量发货成功');
      
      // 刷新订单列表
      fetchOrders();
      
      // 清空选择
      if (orderTableRef.value) {
        orderTableRef.value.clearSelection();
      }
    } catch (error) {
      console.error('批量发货失败', error);
      ElMessage.error('批量发货失败: ' + (error.message || '未知错误'));
    } finally {
      loading.value = false;
    }
  }).catch(() => {});
};

// 取消订单
const handleCancelOrder = (order) => {
  ElMessageBox.confirm(
    `确定要取消订单【${order.orderNumber}】吗？`,
    '取消订单',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }
  ).then(async () => {
    try {
      loading.value = true;
      
      // 取消订单
      await sellerStore.cancelOrder(order.id);
      
      ElMessage.success('订单取消成功');
      
      // 刷新订单列表
      fetchOrders();
    } catch (error) {
      console.error('订单取消失败', error);
      ElMessage.error('订单取消失败: ' + (error.message || '未知错误'));
    } finally {
      loading.value = false;
    }
  }).catch(() => {});
};

// 退款处理
const handleRefundOrder = (order) => {
  ElMessageBox.confirm(
    `确定要对订单【${order.orderNumber}】进行退款操作吗？`,
    '退款确认',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }
  ).then(async () => {
    try {
      loading.value = true;
      
      // 退款
      await sellerStore.refundOrder(order.id);
      
      ElMessage.success('退款操作成功');
      
      // 刷新订单列表
      fetchOrders();
    } catch (error) {
      console.error('退款操作失败', error);
      ElMessage.error('退款操作失败: ' + (error.message || '未知错误'));
    } finally {
      loading.value = false;
    }
  }).catch(() => {});
};

// 获取订单列表
const fetchOrders = async () => {
  loading.value = true;
  try {
    const ordersData = await sellerStore.fetchOrders();
    orders.value = ordersData;
    
    // 获取订单统计数据
    orderStats.value = await sellerStore.getOrderStats();
  } catch (error) {
    console.error('获取订单列表失败', error);
    ElMessage.error('获取订单列表失败: ' + (error.message || '未知错误'));
    orders.value = [];
  } finally {
    loading.value = false;
  }
};

// 组件挂载时获取数据
onMounted(() => {
  fetchOrders();
});
</script>

<style scoped>
.seller-order-management-container {
  padding: 20px;
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 22px;
  font-weight: bold;
  display: flex;
  align-items: center;
}

.page-title .el-icon {
  margin-right: 8px;
  font-size: 24px;
  color: var(--primary-color);
}

.filter-card {
  margin-bottom: 20px;
}

.filter-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
}

.filter-item {
  width: 220px;
}

.date-range {
  width: 350px;
}

.filter-actions {
  margin-left: auto;
}

.stats-row {
  margin-bottom: 20px;
}

.stats-card {
  margin-bottom: 10px;
  transition: all 0.3s;
}

.stats-card:hover {
  transform: translateY(-5px);
}

.stats-content {
  display: flex;
  align-items: center;
}

.stats-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
}

.stats-icon .el-icon {
  font-size: 24px;
  color: white;
}

.pending-icon {
  background-color: #e6a23c;
}

.today-icon {
  background-color: #409eff;
}

.income-icon {
  background-color: #67c23a;
}

.total-icon {
  background-color: #8e44ad;
}

.stats-info {
  flex: 1;
}

.stats-title {
  font-size: 14px;
  color: #909399;
  margin-bottom: 5px;
}

.stats-value {
  font-size: 24px;
  font-weight: bold;
  color: #303133;
}

.order-list-card {
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-weight: bold;
  font-size: 16px;
}

.card-actions {
  display: flex;
  gap: 10px;
}

.order-buyer-phone {
  font-size: 12px;
  color: #909399;
  margin-top: 3px;
}

.order-product-name {
  font-weight: bold;
  margin-bottom: 5px;
}

.order-product-price {
  font-size: 12px;
  color: #909399;
}

.order-price {
  color: #f56c6c;
  font-weight: bold;
}

.pagination-container {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.order-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.order-number {
  margin: 0;
  font-size: 18px;
}

.detail-section {
  margin-bottom: 20px;
}

.section-title {
  font-weight: bold;
  margin-bottom: 15px;
  padding-left: 10px;
  border-left: 3px solid var(--primary-color);
}

.detail-item {
  margin-bottom: 10px;
  display: flex;
}

.detail-label {
  color: #606266;
  width: 100px;
}

.detail-value {
  flex: 1;
}

.product-table {
  margin-bottom: 15px;
}

.order-amount {
  text-align: right;
  padding: 10px 20px;
}

.amount-item {
  margin-bottom: 5px;
}

.amount-label {
  color: #606266;
  margin-right: 10px;
}

.amount-value {
  font-weight: bold;
}

.amount-item.total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #dcdfe6;
}

.amount-item.total .amount-value {
  color: #f56c6c;
  font-size: 18px;
}

.order-note {
  padding: 10px;
  background-color: #f5f7fa;
  border-radius: 4px;
  white-space: pre-wrap;
}

.timeline-remark {
  color: #606266;
  margin-top: 5px;
  font-size: 12px;
}

.empty-data {
  padding: 40px 0;
  text-align: center;
}

@media (max-width: 768px) {
  .filter-container {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-item, .date-range {
    width: 100%;
  }
  
  .filter-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .card-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .order-detail-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .detail-item {
    flex-direction: column;
  }
  
  .detail-label {
    width: 100%;
    margin-bottom: 5px;
  }
}
</style> 